<?php

namespace app\api\controller\auth;

use app\api\controller\AuthBase;
use app\common\model\mysql\AdminRule as AdminRuleModel;
class Rule extends AuthBase
{
    public static $name = 'controller.auth.Rule';
    /**
     * 当前权限组列表
     * @return void
     */
    public function list()
    {
        try{
            $result = [
                'list'=>[],
                'remark'=>'',
            ];
            $adminGroup =  \app\api\business\AdminGroupBus::getConditionalQuery(['id'=>$this->groupId]);
            if($adminGroup){
                if($adminGroup['rules'] =="*"){
                    $ids = \app\api\business\AdminRoleBus::getIdList();
                }else{
                    $ids = explode(",",$adminGroup['rules']);
                }
                $role= \app\api\business\AdminRoleBus::getMultipleData($ids);
                $roleResult =  \app\api\business\AdminRoleBus::getTreeData($role);
                $result['list'] = $roleResult;
            }
            return returnResult(config("config.code.success"),config("config.describe.success"),$result);
        }catch (\Exception $e){
            exception($e,self::$name.'.index');
        }
    }

    /**
     * 编辑当前权限组的路由
     * @return void
     */
    public function edit()
    {
        try{
            $id = input('id');
            $role_menu = new AdminRuleModel();
            $row = $role_menu->find($id);
            var_dump($row);
        }catch (\Exception $e){
            exception($e,self::$name.'.edit');
        }
    }
}